﻿using System.ComponentModel;

namespace Sidvall.UI.Messaging
{
    public class FilterParameter : INotifyPropertyChanged
    {
        #region Public Members

        public event PropertyChangedEventHandler PropertyChanged;

        #region TextFilter

        private string _TextFilter;
        public string TextFilter
        {
            get
            {
                return _TextFilter;
            }
            set
            {
                value = Sidvall.Business.ValidationManager.GetValidString(value, false, null);
                if (_TextFilter == value)
                    return;
                _TextFilter = value;
                OnPropertyChanged(nameof(TextFilter));
            }
        }

        #endregion
        #region RowCount

        private int _RowCount;
        public int RowCount
        {
            get
            {
                return _RowCount;
            }
            set
            {
                if (_RowCount == value)
                    return;
                _RowCount = value;
                OnPropertyChanged(nameof(RowCount));
            }
        }

        #endregion
        #region PreloadList

        private bool _PreloadList;
        public bool PreloadList
        {
            get
            {
                return _PreloadList;
            }
            set
            {
                if (_PreloadList == value)
                    return;
                _PreloadList = value;
                OnPropertyChanged(nameof(PreloadList));
            }
        }

        #endregion
        #region AllowEdit

        private bool _AllowEdit;
        public bool AllowEdit
        {
            get
            {
                return _AllowEdit;
            }
            set
            {
                if (_AllowEdit == value)
                    return;
                _AllowEdit = value;
                OnPropertyChanged(nameof(AllowEdit));
            }
        }

        #endregion
        #region AllowDelete

        private bool _AllowDelete;
        public bool AllowDelete
        {
            get
            {
                return _AllowDelete;
            }
            set
            {
                if (_AllowDelete == value)
                    return;
                _AllowDelete = value;
                OnPropertyChanged(nameof(AllowDelete));
            }
        }

        #endregion
        #region ShowList

        private bool _ShowList;
        public bool ShowList
        {
            get
            {
                return _ShowList;
            }
            set
            {
                if (_ShowList == value)
                    return;
                _ShowList = value;
                OnPropertyChanged(nameof(ShowList));
            }
        }

        #endregion
        #region SortItems

        private System.Collections.ObjectModel.Collection<Sidvall.Data.SortItem> _SortItems;
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public System.Collections.ObjectModel.Collection<Sidvall.Data.SortItem> SortItems
        {
            get
            {
                return _SortItems;
            }
            set
            {
                _SortItems = value;
                OnPropertyChanged(nameof(SortItems));
            }
        }

        #endregion

        #region OnPropertyChanged

        protected void OnPropertyChanged(string propertyName)
        {
            OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
        }
        protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged.Invoke(this, args);
        }

        #endregion

        #endregion
        #region Constructors

        public FilterParameter()
        {
            this._RowCount = 1000;
            this._SortItems = new System.Collections.ObjectModel.Collection<Data.SortItem>();
        }

        #endregion
    }
}
